<?php

include('./init.php');

header('Content-Type: text/xml; charset=UTF-8');

echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
echo '<?xml-stylesheet href="http://www.televisiontunes.com/css/css.css" type="text/css"?>' . "\n";
echo '<!-- TelevisionTunes.com RSS, generated on ' . date('r') . ' -->' . "\n";
echo '
<rss version="2.0">
<channel>
<title>TelevisionTunes.com latest songs</title>
<link>' . ABS_URL . '</link>
<description>TV Theme music and songs from 7,856 different television shows. Listen to them all in MP3 format.</description>
<language>en</language>
<lastBuildDate>' . date('r') . '</lastBuildDate>' . "\n";

$res = mysql_query("SELECT file_name, file_title, date_added,page_name FROM bj_audio LEFT JOIN pages ON bj_audio.id_parent=pages.id_category ORDER BY date_added DESC LIMIT 30") or die(mysql_error());
if ($res !== FALSE && mysql_num_rows($res)) {
    while($lin = mysql_fetch_assoc($res)) {
    echo "<item>\n";
    echo '<category>' . $lin['page_name'] . ' Theme Songs</category>' . "\n";
    echo '<link>' . utils::create_href($lin['file_title']) . '</link>' . "\n";
    echo '<title>' . utf8_encode(htmlspecialchars(str_replace('.mp3', '', $lin['file_name']))) . '</title>' ."\n";
    echo '<description><![CDATA[<a href="' . utils::create_href($lin['file_title']) . '">' . utf8_encode(htmlspecialchars(str_replace('.mp3', '', $lin['file_name']))) . '</a><br>Category: <a href="' . ABS_URL . strtolower($lin['page_name']) . '-theme-songs.html">' . $lin['page_name'] . ' theme songs' . '</a>]]></description>' . "\n";
    echo '<guid>' . utils::create_href($lin['file_title']) . '</guid>';
    echo '<pubdate>' . date('r', strtotime($lin['date_added'])) . '</pubdate>';
    echo "</item>\n";
    
        //echo '<option value="' . utils::create_href($lin['file_title']) . '">' . htmlspecialchars(str_replace('.mp3', '', $lin['file_name'])) . '</option>';
    }
    mysql_free_result($res);
}
?>
</channel>
</rss>